//
//  QSUserManager.h
//  DigitalEconomy_iOS
//
//  Created by Ding on 2020/3/23.
//  Copyright © 2020 DingC. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "QSUserModel.h"
// .h
#define single_interface(class)  + (class *)shared##class;

// .m
// \ 代表下一行也属于宏
// ## 是分隔符
#define single_implementation(class) \
static class *_instance; \
 \
+ (class *)shared##class \
{ \
    if (_instance == nil) { \
        _instance = [[self alloc] init]; \
    } \
    return _instance; \
} \
 \
+ (id)allocWithZone:(NSZone *)zone \
{ \
    static dispatch_once_t onceToken; \
    dispatch_once(&onceToken, ^{ \
        _instance = [super allocWithZone:zone]; \
    }); \
    return _instance; \
}
@interface QSUserManager : NSObject
single_interface(QSUserManager)
/** 保存用户*/
- (void)saveUser:(QSUserModel *)user;
/** 删除用户*/
- (void)removeUser;

/**
 * @brief返回首页操作
 */
- (void)turnToHomeViewController;

/**
 * @brief弹出登录页面操作
 */
- (void)turnToLoginViewController;

/**
 * 登陆成功的回调
 */
@property (nonatomic, copy) void (^LoginSuccessBlock)(void);

/**
 * 需要登陆的回调
 */
@property (nonatomic, copy) void (^NeedLoginBlock)(void);

// 获得当前账号
@property (nonatomic, readonly) QSUserModel *user;\
@end

